home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3 / CHAPTE23 / EX3.C < prev    next >
C/C++ Source or Header  |  1995-03-19  |  2KB  |  45 lines

  1. #include <genstub.c>
  2.  
  3. LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4. {
  5.    static int nCount = 0;       // Count times atom is added. 
  6.    switch (uMsg)                // Process windows messages.
  7.    {
  8.        case WM_COMMAND:         // Process menu items.
  9.                switch (wParam)
  10.                {
  11.                    case IDM_TEST:
  12.                         {
  13.                            HDC hDC = GetDC( hWnd );
  14.                            ATOM atom = GlobalFindAtom( "Test String" );
  15.                            if (atom)
  16.                               TextOut( hDC, 0, 0, "Test String Found.      ", 18 );
  17.                            else
  18.                               TextOut( hDC, 0, 0, "Test String Not Found.", 22 );
  19.                            GlobalAddAtom( "Test String" );
  20.                            nCount++;
  21.                            ReleaseDC( hWnd, hDC );
  22.                         }
  23.                         break;
  24.                    case IDM_EXIT:      
  25.                         DestroyWindow (hWnd) ;
  26.                         break;
  27.               }
  28.               break;
  29.       case WM_DESTROY:
  30.               { 
  31.                  int i;
  32.                  ATOM atom = GlobalFindAtom( "Test String" );
  33.                  for (i = 0 ; i < nCount ; i++)
  34.                     GlobalDeleteAtom( atom );
  35.                  PostQuitMessage( 0 );
  36.               }
  37.               break;
  38.       default:
  39.               return DefWindowProc( hWnd, uMsg, wParam, lParam );
  40.    }
  41.    return( 0L );
  42. }
  43.  
  44. #include <about.c>
  45.